chiSquareFitTestDialog <- function(){
	initializeDialog(title=gettext("Chi-Square Goodness of Fit Test", domain="R-RcmdrPlugin.TeachingExtras"))
	theoreticalBox <- variableListBox(top, Numeric(), title=gettext("Theoretical probability (pick one)", domain="R-RcmdrPlugin.TeachingExtras"))
	observedBox <- variableListBox(top, Numeric(), title=gettext("Observed frequency (pick one)", domain="R-RcmdrPlugin.TeachingExtras"))
	onOK <- function(){
		theoretical <- getSelection(theoreticalBox)
		observed <- getSelection(observedBox)
		if (length(theoretical)==0 || length(observed)==0) {
			errorCondition(recall=chiSquareFitTestDialog, message=gettextRcmdr("You must select a variable with the theoretical probabilities and a variable with the observed frequencies."))
			return()
		}
		closeDialog()
		.activeDataSet <- ActiveDataSet()
		doItAndPrint(paste("chisq.test(", .activeDataSet, "$", observed, ", p=", .activeDataSet, "$", theoretical, ")", sep=""))
		tkfocus(CommanderWindow())
	}
	OKCancelHelp(helpSubject="chisq.test")
	tkgrid(getFrame(theoreticalBox), getFrame(observedBox), sticky="nw")
	tkgrid(buttonsFrame, columnspan=2, sticky="w")
	dialogSuffix(rows=2, columns=2)
}